var app = angular.module('JiangGanApp')
app.controller('LoginCtrl', ['$scope','$state','$rootScope',LoginCtrl]);

function LoginCtrl($scope,$state,$rootScope){
	$scope.account = ''
	$scope.password= ''

	$scope.accountPair = [
		{
			acc:'admin',
			pwd:'admin'
		},
		{
			acc:'',
			pwd:''
		}
	]

	$scope.checkKeyUp = function(e){
		var keycode = window.event ? e.keyCode : e.which;//获取按键编码  
            if (keycode == 13) {  
                $scope.checkLogin()//如果等于回车键编码执行方法  
            }  
	}

	$scope.checkLogin = function(){
		if($scope.account==''||$scope.password==''){
			$scope.password=''
			alert('请输入账号与密码！')
		}else{
			//校验正确
			if($scope.account!='admin'||$scope.password!='admin'){
				alert('用户名不存在或密码不正确！')
				$scope.password=''
			}else{
				alert('登录成功！')
				$rootScope.account = $scope.account;
				$state.go('app.netbar.main')

			}
		}
	}

}
